/************************************************************
 * Project Name         [Thinking_In_Java]
 * File Name            [Wall.java]
 * Creation Date        [22-Jul-2014]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ************************************************************/
package pkg_03_game.tankwar_local.version_8;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

/**
 * 墙体
 * 
 * @author 不落的太阳(Sean Yang)
 * @version 1.0
 * @since JDK 6
 * 
 */
public class Wall {

	/** 墙体的坐标 */
	private int x = 0;
	private int y = 0;

	private final MainFrame client;

	/** 墙体的高度和宽度 */
	static int width = 30;
	static int height = 30;

	/** 墙体是否存在 */
	private boolean live = true;

	public Wall(int x, int y, MainFrame client) {
		super();
		this.x = x;
		this.y = y;
		this.client = client;
	}

	/**
	 * 绘制墙体
	 * 
	 * @param g
	 */
	public void paint(Graphics g) {
		if (!isLive()) {
			client.walls.remove(this);
		}
		Color color = g.getColor();
		g.setColor(new Color(153, 0, 0));
		g.fillRect(x, y, width, height);
		g.setColor(Color.DARK_GRAY);
		g.drawRect(x, y, width, height);
		g.setColor(color);
	}

	/**
	 * 碰撞检测
	 * 
	 * @return
	 */
	public Rectangle getRectangle() {
		return new Rectangle(x, y, width, height);
	}

	public boolean isLive() {
		return live;
	}

	public void setLive(boolean live) {
		this.live = live;
	}
}
